package com.google.code.sip.ucenter.dao.mongo;

import java.util.List;

import com.google.code.sip.core.dao.Page;
import com.google.code.sip.core.dao.mongo.GenericMongoDao;
import com.google.code.sip.ucenter.dao.CreditLogDao;
import com.google.code.sip.ucenter.model.CreditLog;
import com.google.code.sip.ucenter.model.User;

/**
 * 用户积分对象的泛型DAO类.
 * 
 * @author Liuye
 */

public class CreditLogDaoImpl extends GenericMongoDao<CreditLog, String>
		implements CreditLogDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.google.code.sip.ucenter.dao.mongo.CreditLogDao#findByUser(com.google.
	 * code.ucenter.model.User)
	 */
	public List<CreditLog> findByUser(User user) {
		return super.findByProperty("username", user.getUsername());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.google.code.sip.ucenter.dao.mongo.CreditLogDao#findByUser(com.google.
	 * code.ucenter.model.User, com.google.code.sip.core.dao.Page)
	 */
	public Page<CreditLog> findByUser(User user, Page<CreditLog> page) {
		page.addFilter("username", user.getUsername());
		return super.findByPage(page);
	}

}
